package ar.com.candoit.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import ar.com.candoit.beans.Student;
import ar.com.candoit.dao.StudentDao;

@Service("StudentService")
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
public class StudentServiceImpl implements StudentService {

	@Autowired
	private StudentDao studentDao;

	public StudentServiceImpl() {
	}

	@Transactional(propagation = Propagation.REQUIRED, readOnly = false)
	public void addStudent(Student student) {
		studentDao.saveStudent(student);
	}

	public List<Student> listStudent() {
		return studentDao.listStudent();
	}

	public Student finByDesc(String text) {
		return null;
	}

	public Student findStudentNyName(String student_name) {
		return studentDao.findStudentByName(student_name);
	}

	@Override
	public Student findStudentById(long student_id) {
		return studentDao.findStudentById(student_id);
	}

	@Override
	public void updateStudent(Student student) {
		studentDao.updateStudent(student);
	}

	@Override
	public void deleteStudent(Student student) {
	studentDao.deleteStudent(student);
	}

}